<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script>
        window.onload = function(){
            var div = document.getElementById("div1");
            div.onclick=function(){
                div.style.backgroundColor = "red";
            }

            var btn = document.getElementById("btn1");
            btn.onclick = function(){
                div.onclick();
            }


        }

    </script>
    <style>
        .div1{
            width: 500px;
            height: 500px;
            background-color: yellow;
        }
    </style>
</head>
<body>

    <div class="div1" id="div1"></div>
    <button id="btn1">按钮</button>
    
</body>
</html>